package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 攻略文章
 */
@Getter
@Setter
public class StrategyDetail extends BaseDomain {
    public static final int STATE_NOMAL = 0;//草稿
    public static final int STATE_RELEASE = 1;//发布

    //标题
    private String title;
    //创建时间
    private Date createTime;
    //发布时间
    private Date releaseTime;
    //序号
    private Integer sequence;
    //所属分类
    private StrategyCatalog catalog;
    //封面
    private String coverUrl;
    //状态
    private Integer state;
    //文章内容
    private StrategyContent strategyContent;


    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("sequence", sequence);
        map.put("state", state);
        map.put("coverUrl", coverUrl);
        //分类对象
        if(catalog!=null){
            map.put("catalogId", catalog.getId());
            //攻略对象
            if(catalog.getStrategy()!=null){
                map.put("strategyId", catalog.getStrategy().getId());
            }
        }

        return JSONUtil.toJSONString(map);
    }

}